﻿

using System;
using System.Diagnostics;
using System.Text.RegularExpressions;
using Demo.Services.Test.Console.UserService;
using Demo.Services.Test.Console.ActionService;

namespace Demo.Services.Test.Console
{
    class Program
    {
        [STAThread]
        static void Main(string[] args)
        {
            //UserServiceClient client = new UserServiceClient();
            //var user = client.GetUserDTOWithName("luoliang");
            //var user1 = client.GetUserDTOWithName("luoliang");

            ////var isT = client.ExistsWithUserName("luoliang");

            //client.ChangePassword(user.Name, user.Password, "demo");
            //user = client.GetUserDTOWithName("luoliang");


            //ModuleService.ModuleServiceClient client = new ModuleService.ModuleServiceClient();

            //ActionService.ActionServiceClient actionClient = new ActionServiceClient();
            //var actions = actionClient.GetActionDTOWithUserId(1);

            //TestEvent ts = new TestEvent();
            //ts.TestEventArgs += Test;
            //System.Console.WriteLine("press  key to increase total");
            //var ret = ts.Add(1, 2);

            //var i = 1;

            //Process current = Process.GetCurrentProcess();
            //var processs = Process.GetProcessesByName(current.ProcessName);

            //string Url = @"http://www.baidu.com";
            //string HtmlCode = @"";// o.GetRemoteHtmlCode(Url);
            //string s = GetHref(HtmlCode);



            System.Console.WriteLine("press  key to increase total");
            System.Console.WriteLine(test.My.ToString());
            System.Console.Read();
        }

        private static void Test(Object obj,TestEventArgs args)
        {
            System.Console.WriteLine("TestEventArgs");
        }

        public static string GetHref(string HtmlCode)
        {
            string MatchVale = "";
            string Reg = @"(h|H)(r|R)(e|E)(f|F) *= *('|"")?((\w|\\|\/|\.|:|-|_)+)('|""| *|>)?";
            foreach (Match m in Regex.Matches(HtmlCode, Reg))
            {
                MatchVale += (m.Value).ToLower().Replace("href=", "").Trim() + "||";
            }
            return MatchVale;
        }

    }

    public enum test
    { 
        My,
        You
    }

    public class TestEvent
    {
        public Int32 Add(Int32 x,Int32 y)
        {
            var tea = new TestEventArgs();
            tea.DateTime = DateTime.Now;
            tea.id = 1;
            EventHandler<TestEventArgs> handle = TestEventArgs;
            if (handle != null)
                handle(this, tea);
            return x + y;
        }

        public event EventHandler<TestEventArgs> TestEventArgs;
    }

    public class TestEventArgs : EventArgs
    {
        public Int32 id { get; set; }

        public DateTime DateTime { get; set; }
    }
}
